from kafka import KafkaConsumer

conf = {
    'bootstrap_servers': '192.168.0.221:9092',
    'topic_name': 'test0210',
    'topic_name_a': 'test0210a',
    'consumer_id': 'consumer-id'
}
print("*****************开始实例化消费者********************")
# print (start consumer)
consumer = KafkaConsumer(conf['topic_name'],
                        bootstrap_servers=conf['bootstrap_servers'],
                        group_id=conf['consumer_id'])
print("*****************实例化消费者成功*********************")
i=0
for message in consumer:

    i = i+1
    print("==========Kafka消费者接收到第%s条数据==========" %i)
    print("%s:%d:%d: key=%s value=%s" % (message.topic, message.partition,message.offset, message.key,message.value))

# print(end consumer)